package com.my.style.ui.fragment;


import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.widget.ListView;

import com.my.style.adapter.WardrobeAdapter;
import com.my.style.basemodul.R;
import com.sv.jm.baselibrary.base.BaseFragment;
import com.sv.jm.baselibrary.event.EventAction;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * A simple {@link Fragment} subclass.
 */
public class WardrobeFragment extends BaseFragment {
    /**
     * 右侧边栏导航区域
     */
    ListView lvYG;
    SwipeRefreshLayout pull_refresh;
    WardrobeAdapter adapter;
    List<String> datas = new ArrayList<>();

    @Override
    public int getFragmentLayout() {
        return R.layout.fragment_txl;
    }

    @Override
    public void OnCoustomLayoutCreated(View v) {
        lvYG = findView(v, R.id.lvYG);
        pull_refresh = findView(v, R.id.pull_refresh);
        adapter = new WardrobeAdapter(R.layout.item_yg, getContext());
        lvYG.setAdapter(adapter);
        for (int i = 0; i < 10; i++) {
            int index = i % 7 + 1;
            datas.add("周" + index + "上架");
        }
        adapter.setDatas(datas);
    }

    /**
     * 组织数据源
     *
     * @return
     */
    private void initDatas() {

    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void setListeners() {
        pull_refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
               new Timer().schedule(new TimerTask() {
                   @Override
                   public void run() {
                       getActivity().runOnUiThread(new Runnable() {
                           @Override
                           public void run() {
                                pull_refresh.setRefreshing(false);
                           }
                       });
                   }
               },3000);
            }
        });
    }

    @Override
    public void otherClick(View v) {
    }

    @Override
    protected void onRefreshData() {

    }

    @Override
    public void onOtherActionReceiver(EventAction eventAction) {

    }
}
